/*
 * Copyright [2011] [Ambud Sharma/ODep Monitor]

   Licensed under the Apache License, Version 2.0 (the "License");

   you may not use this file except in compliance with the License.

   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software

   distributed under the License is distributed on an "AS IS" BASIS,

   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

   See the License for the specific language governing permissions and

   limitations under the License.
 */
package edu.uwsp.orion.odepm.main.client;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.LegendPosition;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.visualizations.corechart.AxisOptions;
import com.google.gwt.visualization.client.visualizations.corechart.LineChart;
import com.google.gwt.visualization.client.visualizations.corechart.Options;
import com.google.gwt.visualization.client.visualizations.corechart.PieChart;
import com.google.gwt.visualization.client.visualizations.corechart.PieChart.PieOptions;

import edu.uwsp.orion.odepm.main.shared.DashboardMain;
import edu.uwsp.orion.odepm.main.shared.JobSummary;
import edu.uwsp.orion.odepm.main.shared.Node;
import edu.uwsp.orion.odepm.main.shared.Rack;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.StackPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class ODepMonitor_Stage2 implements EntryPoint {
	
	private ListHandler<JobSummary> sortHandler = new ListHandler<JobSummary>(Collections.<JobSummary>emptyList());
	
	DataTable dtDiskUsage,dtCPU,dtMemory,dtUsage;
	PieChart chartDiskUsage,chartClusterUsage;
	RootPanel rp;
	VerticalPanel verticalPanel;
	AbsolutePanel apHeader,apBody,apInfoPanel,apJobSummary,absolutePanel_1,apDiskUsage,apUsage,apCPUStats,apMemoryStats,apChartContainer;
	HorizontalPanel horizontalPanel;
	Label lblLoggedInAs,lblClusterSummary,lblNoOfNodes,lblDiskSpace_perm,lblHeapSize_perm,lblCpuCount_perm,lblMasternode,labelNamenodeAddress,lblNumNodes,lblClusterGflops,lblDiskSpace,lblHeapSize,lblCpuCount,lblGfops,lblUpdatedMinute;
	Image imgClusterStatus;
	CellTable<JobSummary> cellTable;
	
	public void onModuleLoad() {
		
		RootPanel rp=RootPanel.get("mainpanel");
		rp.getElement().getStyle().setPosition(Position.RELATIVE);
		rp.setSize("1000px", "900px");

		verticalPanel = new VerticalPanel();
		verticalPanel.setStyleName("none");
		rp.add(verticalPanel, 0, 0);
		verticalPanel.setSize("1000px", "785px");
		
		apHeader = new AbsolutePanel();
		apHeader.setStyleName("background_main");
		verticalPanel.add(apHeader);
		apHeader.setHeight("82px");
		
		Image imageHeader = new Image("images/HeaderMonitor.png");
		apHeader.add(imageHeader, 0, 0);
		imageHeader.setSize("1000px", "82px");
		
		lblLoggedInAs = new Label("Logged in as");
		lblLoggedInAs.setStyleName("login_label");
		apHeader.add(lblLoggedInAs, 10, 10);
		lblLoggedInAs.setSize("187px", "19px");
		
		apBody = new AbsolutePanel();
		apBody.setStyleName("background_main");
		verticalPanel.add(apBody);
		apBody.setSize("999px", "702px");
		
		lblClusterSummary = new Label("Cluster Summary");
		lblClusterSummary.setStyleName("gwt-Header");
		apBody.add(lblClusterSummary, 10, 7);
		lblClusterSummary.setSize("226px", "26px");
		
		apInfoPanel = new AbsolutePanel();
		apInfoPanel.setStyleName("border");
		apBody.add(apInfoPanel, 10, 35);
		apInfoPanel.setSize("347px", "210px");
		
		lblNoOfNodes = new Label("No. of Nodes:");
		lblNoOfNodes.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblNoOfNodes, 10, 39);
		
		lblDiskSpace_perm = new Label("Disk Space:");
		lblDiskSpace_perm.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblDiskSpace_perm, 10, 68);
		lblDiskSpace_perm.setSize("105px", "23px");
		
		lblHeapSize_perm = new Label("Heap Size:");
		lblHeapSize_perm.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblHeapSize_perm, 10, 97);
		lblHeapSize_perm.setSize("105px", "23px");
		
		lblCpuCount_perm = new Label("CPU Core Count:");
		lblCpuCount_perm.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblCpuCount_perm, 10, 126);
		lblCpuCount_perm.setSize("134px", "23px");
		
		lblMasternode = new Label("NameNode:");
		lblMasternode.setStyleName("gwt-Label-Small-Bold");
		apInfoPanel.add(lblMasternode, 10, 10);
		
		labelNamenodeAddress = new Label("0.0.0.0");
		labelNamenodeAddress.setStyleName("gwt-Label-Small-Bold");
		apInfoPanel.add(labelNamenodeAddress, 153, 10);
		labelNamenodeAddress.setSize("156px", "19px");
		
		lblClusterGflops = new Label("Cluster GFLOPS:");
		lblClusterGflops.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblClusterGflops, 10, 153);
		
		lblNumNodes = new Label("0");
		lblNumNodes.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblNumNodes, 153, 39);
		lblNumNodes.setSize("105px", "23px");
		
		lblDiskSpace = new Label("0 TB");
		lblDiskSpace.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblDiskSpace, 153, 68);
		lblDiskSpace.setSize("105px", "23px");
		
		lblHeapSize = new Label("");
		lblHeapSize.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblHeapSize, 153, 97);
		lblHeapSize.setSize("56px", "23px");
		
		lblCpuCount = new Label("0");
		lblCpuCount.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblCpuCount, 153, 126);
		lblCpuCount.setSize("105px", "23px");
		
		lblGfops = new Label("0 GFOPS");
		lblGfops.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblGfops, 153, 153);
		lblGfops.setSize("105px", "23px");
		
		Label lblCluster = new Label("Health:");
		lblCluster.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblCluster, 10, 181);
		lblCluster.setSize("129px", "19px");
		
		lblMbMb = new Label("MB");
		lblMbMb.setStyleName("gwt-Label-Small");
		apInfoPanel.add(lblMbMb, 215, 97);
		lblMbMb.setSize("83px", "23px");
				
		Label lblJobSummary = new Label("Job Summary");
		lblJobSummary.setStyleName("gwt-Header");
		apBody.add(lblJobSummary, 10, 253);
		lblJobSummary.setSize("191px", "28px");
		
		apJobSummary = new AbsolutePanel();
		apJobSummary.setStyleName("borderJob");
		apBody.add(apJobSummary, 10, 282);
		apJobSummary.setSize("347px", "395px");
		
		cellTable = new CellTable<JobSummary>();
		cellTable.setPageSize(35);
		cellTable.setTableLayoutFixed(true);
		cellTable.setStyleName("GPBYFDEGE_!");
		cellTable.addColumnSortHandler(sortHandler);
		apJobSummary.add(cellTable, 0, 0);
		cellTable.setSize("349px", "395px");
		cellTable.setFocus(false);	
		cellTable.setLoadingIndicator(new Image("images/CloseIcon.png"));
				
		TextColumn<JobSummary> jobIDColumn = new TextColumn<JobSummary>() {
		      @Override
		      public String getValue(JobSummary object) {
		        return object.jobID.substring(0, object.jobID.length()-6)+"..";
		      }
		    };		
		 
		jobIDColumn.setCellStyleNames(".JobTableHeaderText");
		jobIDColumn.setSortable(true);
		cellTable.addColumn(jobIDColumn, "ID");		
		cellTable.setColumnWidth(jobIDColumn, "78px");
		sortHandler.setComparator(jobIDColumn, new Comparator<JobSummary>() {
			public int compare(JobSummary o1, JobSummary o2) {
				return o1.jobID.compareTo(o2.jobID);
			}
		});
		
		TextColumn<JobSummary> jobNameColumn = new TextColumn<JobSummary>() {
		      @Override
		      public String getValue(JobSummary object) {
		        return object.jobName;
		      }
		    };
		jobNameColumn.setCellStyleNames(".JobTableHeaderText");
		jobNameColumn.setSortable(true);
		cellTable.addColumn(jobNameColumn, "Name");
		cellTable.setColumnWidth(jobNameColumn, "74px");
		sortHandler.setComparator(jobNameColumn, new Comparator<JobSummary>() {
			public int compare(JobSummary o1, JobSummary o2) {
				return o1.jobName.compareTo(o2.jobName);
			}
		});
		
		TextColumn<JobSummary> jobMapColumn = new TextColumn<JobSummary>() {
		      @Override
		      public String getValue(JobSummary object) {
		        return object.mapProgress+"";
		      }
		    };
		
		cellTable.addColumn(jobMapColumn, "Map");
		cellTable.setColumnWidth(jobMapColumn, "62px");
		
		TextColumn<JobSummary> jobreduceColumn = new TextColumn<JobSummary>() {
		      @Override
		      public String getValue(JobSummary object) {
		        return object.reduceProgress+"";
		      }
		    };
		
		cellTable.addColumn(jobreduceColumn, "Reduce");
		cellTable.setColumnWidth(jobreduceColumn, "62px");
		
		TextColumn<JobSummary> jobOverallColumn = new TextColumn<JobSummary>() {
		      @Override
		      public String getValue(JobSummary object) {
		        return object.overallProgress+"";
		      }
		    };		
		cellTable.addColumn(jobOverallColumn, "Overall");
		cellTable.setColumnWidth(jobOverallColumn, "62px");
		
		Label lblClusterStatistics = new Label("Cluster Statistics");
		lblClusterStatistics.setStyleName("gwt-Header");
		apBody.add(lblClusterStatistics, 365, 7);
		lblClusterStatistics.setSize("226px", "29px");
		
		apChartContainer = new AbsolutePanel();
		apChartContainer.setStyleName("none");
		apBody.add(apChartContainer, 365, 35);
		apChartContainer.setSize("622px", "360px");
		
		final AbsolutePanel apUsage_1 = new AbsolutePanel();
		apUsage_1.setStyleName("border");
		apChartContainer.add(apUsage_1, 393, 0);
		apUsage_1.setSize("227px", "177px");
		
		apDiskUsage = new AbsolutePanel();
		apDiskUsage.setStyleName("border");
		apChartContainer.add(apDiskUsage, 393, 185);
		apDiskUsage.setSize("227px", "173px");
		
		apCPUStats = new AbsolutePanel();
		apCPUStats.setStyleName("border");
		apChartContainer.add(apCPUStats, 0, 0);
		apCPUStats.setSize("385px", "177px");
		
		apMemoryStats = new AbsolutePanel();
		apMemoryStats.setStyleName("border");
		apChartContainer.add(apMemoryStats, 0, 185);
		apMemoryStats.setSize("385px", "173px");
		
		Label lblTopology = new Label("Cluster Topology");
		lblTopology.setStyleName("gwt-Header");
		apBody.add(lblTopology, 365, 401);
		lblTopology.setSize("303px", "28px");
		
		Button btnDeployNew = new Button("Deploy New");
		btnDeployNew.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				JobDeployer deployer=new JobDeployer();
				deployer.center();
			}
		});
		btnDeployNew.setText("Launch Dep-Util");
		apBody.add(btnDeployNew, 224, 253);
		btnDeployNew.setSize("135px", "28px");
		
		Button btnFullView = new Button("Full View");
		apBody.add(btnFullView, 906, 401);
		btnFullView.setSize("83px", "29px");
		
		Button btnSettings = new Button("Settings");
		apBody.add(btnSettings, 881, 0);
		btnSettings.setSize("64px", "29px");
		
		Button btnLogout = new Button("Logout");
		apBody.add(btnLogout, 944, 0);
		btnLogout.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				Cookies.removeCookie("authenticated_odep");
			}
		});
		btnLogout.setSize("55px", "29px");
		btnLogout.setText("Logout");
		
		AbsolutePanel absolutePanel = new AbsolutePanel();
		absolutePanel.setStyleName("footerMain");
		apBody.add(absolutePanel, 0, 685);
		absolutePanel.setSize("999px", "17px");
		
		Label lblProjectOrionLogo = new Label("Copyright ODepMonitor");
		absolutePanel.add(lblProjectOrionLogo, 442, 0);
		lblProjectOrionLogo.setStyleName("gwt-Label-Footer-Copyright");
		
		ScrollPanel scrollPanel = new ScrollPanel();
		scrollPanel.setStyleName("border");
		apBody.add(scrollPanel, 365, 429);
		scrollPanel.setSize("622px", "248px");
		
		horizontalPanel = new HorizontalPanel();
		scrollPanel.setWidget(horizontalPanel);
		horizontalPanel.setSize("100%", "100%");
		
		
		Runnable initChart=new Runnable() {
			
			@Override
			public void run() {
				dtUsage=DataTable.create();
				dtUsage.addColumn(ColumnType.STRING, "Status");
				dtUsage.addColumn(ColumnType.NUMBER, "Percentage of Time");
				
				dtUsage.addRows(2);
				dtUsage.setValue(0, 0, "Busy");
				dtUsage.setValue(0, 1, 95);
				dtUsage.setValue(1, 0, "Idle");
				dtUsage.setValue(1, 1, 5);
				PieOptions pieChartOptions=PieOptions.create();
				pieChartOptions.setTitle("Cluster Usage");
				pieChartOptions.set3D(true);
				pieChartOptions.setHeight(180);
				pieChartOptions.setWidth(280);
				
				chartClusterUsage=new PieChart(dtUsage,pieChartOptions);
				apUsage_1.add(chartClusterUsage);
				
			}
		};
		
		
		VisualizationUtils.loadVisualizationApi(initChart, PieChart.PACKAGE);
		
		
		Runnable initChartDisk=new Runnable() {
			
			@Override
			public void run() {
				dtDiskUsage=DataTable.create();
				dtDiskUsage.addColumn(ColumnType.STRING, "Disk Used");
				dtDiskUsage.addColumn(ColumnType.NUMBER, "Terabytes");
				
				dtDiskUsage.addRows(2);
				dtDiskUsage.setValue(0, 0, "Used");
				dtDiskUsage.setValue(0, 1, 0);
				dtDiskUsage.setValue(1, 0, "Free");
				dtDiskUsage.setValue(1, 1, 100);
				pieChartOptions=PieOptions.create();
				pieChartOptions.setTitle("Disk Usage");
				pieChartOptions.set3D(true);
				pieChartOptions.setHeight(180);
				pieChartOptions.setWidth(280);
				pieChartOptions.setColors("red","green");
				
				chartDiskUsage=new PieChart(dtDiskUsage,pieChartOptions);
				apDiskUsage.add(chartDiskUsage);
				
			}
		};
		
		VisualizationUtils.loadVisualizationApi(initChartDisk, PieChart.PACKAGE);
		
		Runnable initChartCPU=new Runnable() {
			
			@Override
			public void run() {
				dtCPU=DataTable.create();
				dtCPU.addColumn(ColumnType.NUMBER, "Percentage");
				
				dtCPU.addRows(1);
				dtCPU.setValue(0, 0, 0);
								
				optionsCPU=Options.create();
				optionsCPU.setTitle("CPU Usage");
				optionsCPU.setHeight(apCPUStats.getElement().getClientHeight());
				optionsCPU.setWidth(apCPUStats.getElement().getClientWidth());
				optionsCPU.setLineWidth(1);
				optionsCPU.setColors("green");
				optionsCPU.setLegend(LegendPosition.BOTTOM);
				AxisOptions vAOption=AxisOptions.create();
				vAOption.setMinValue(0);
				vAOption.setMinValue(100);
				optionsCPU.setVAxisOptions(vAOption);
								
				cpuchart=new LineChart(dtCPU, optionsCPU);
				apCPUStats.add(cpuchart);
			}
		};
		
		VisualizationUtils.loadVisualizationApi(initChartCPU, LineChart.PACKAGE);		
		
		Runnable initChartMemory=new Runnable() {
			
			@Override
			public void run() {
				dtMemory=DataTable.create();
				dtMemory.addColumn(ColumnType.NUMBER, "GB");

				dtMemory.addRows(1);
				dtMemory.setValue(0, 0, 0);						
								
				optionsMemory=Options.create();
				optionsMemory.setTitle("Memory Usage");
				optionsMemory.setHeight(apMemoryStats.getElement().getClientHeight());
				optionsMemory.setWidth(apMemoryStats.getElement().getClientWidth());
				optionsMemory.setLineWidth(1);
				optionsMemory.setLegend(LegendPosition.BOTTOM);
				AxisOptions vAOption=AxisOptions.create();
				vAOption.setMinValue(0);
				vAOption.setMinValue(100);
				optionsMemory.setVAxisOptions(vAOption);
								
				memorychart=new LineChart(dtMemory, optionsMemory);
				apMemoryStats.add(memorychart);
			}
		};
		
		VisualizationUtils.loadVisualizationApi(initChartMemory, LineChart.PACKAGE);
		chartUpdater();
		updateSummary();
		initializeJobTable();
		loadTopology();
	}
	
	PieOptions pieChartOptions;
	
	Options optionsMemory;
	LineChart memorychart;
	
	private void initDashBoard(DashboardMain dbMain){
		
		labelNamenodeAddress.setText(dbMain.nameNode.address+":"+dbMain.nameNode.port);
		lblHeapSize.setText(dbMain.nameNode.heapSize+"");
		lblDiskSpace.setText((((float)dbMain.nameNode.disk_size/(1024*1024*1024))+"").substring(0,((float)dbMain.nameNode.disk_size/(1024*1024*1024)+"").indexOf(".")+4)+" GB");
		lblCpuCount.setText(dbMain.nameNode.core_count+"");
		lblGfops.setText(dbMain.nameNode.gflops+"");
		lblNumNodes.setText(dbMain.nameNode.node_count+"");
		
	}
	
	LineChart cpuchart;
	Options optionsCPU;
	
	private void chartUpdater(){
		updateChartCPU();
		updateChartDisk();
		updateChartMemory();
		updateChartStats();
	}
	
	int repeatInterval=5000;
	Timer timeSummary;
	
	private void updateSummary(){
		DashboardInitializerServiceAsync asyncDashInit=GWT.create(DashboardInitializerService.class);
		asyncDashInit.getInfo(new AsyncCallback<DashboardMain>() {
			
			@Override
			public void onSuccess(DashboardMain result) {						
				initDashBoard(result);
			}
			
			@Override
			public void onFailure(Throwable caught) {
				//Window.alert("Failed to reach server!");
			}
		});			
		timeSummary=new Timer() {
			
			@Override
			public void run() {
				DashboardInitializerServiceAsync asyncDashInit=GWT.create(DashboardInitializerService.class);
				asyncDashInit.getInfo(new AsyncCallback<DashboardMain>() {
					
					@Override
					public void onSuccess(DashboardMain result) {						
						initDashBoard(result);
					}
					
					@Override
					public void onFailure(Throwable caught) {
						//Window.alert("Failed to reach server!");
					}
				});			
			}
		};
		timeSummary.scheduleRepeating(30000);
	}
	
	private void updateChartCPU(){
		Timer timerCPU=new Timer() {
			
			@Override
			public void run() {
				
				ChartUpdaterAsync asynCPUChart=GWT.create(ChartUpdater.class);
				asynCPUChart.updateCPUChart(new AsyncCallback<String>() {
					
					@Override
					public void onSuccess(String result) {
						if(dtCPU.getNumberOfRows()>50){
							dtCPU.removeRow(0);
						}
						dtCPU.addRows(1);						
						dtCPU.setValue(dtCPU.getNumberOfRows()-1, 0, Float.parseFloat(result));
						cpuchart.draw(dtCPU,optionsCPU);
					}
					
					@Override
					public void onFailure(Throwable caught) {
					}
				});
			}
		};
		timerCPU.scheduleRepeating(5000);
	}
	
	private void updateChartMemory(){
		Timer timerMemory=new Timer() {
			
			@Override
			public void run() {
				ChartUpdaterAsync asynMemoryChart=GWT.create(ChartUpdater.class);
				asynMemoryChart.updateMemoryChart(new AsyncCallback<String>() {
					
					@Override
					public void onSuccess(String result) {
						if(dtMemory.getNumberOfRows()>50){
							dtMemory.removeRow(0);
						}
						dtMemory.addRows(1);						
						dtMemory.setValue(dtMemory.getNumberOfRows()-1, 0, Float.parseFloat(result));
						memorychart.draw(dtMemory,optionsMemory);
					}
					
					@Override
					public void onFailure(Throwable caught) {
					}
				});
			}
		};
		timerMemory.scheduleRepeating(5000);
	}
	
	private void updateChartDisk(){
		Timer timerDisk=new Timer() {
			
			@Override
			public void run() {
				ChartUpdaterAsync asyncDiskUpdate=GWT.create(ChartUpdater.class);
				asyncDiskUpdate.updateDiskChart(new AsyncCallback<String>() {
					
					@Override
					public void onSuccess(String result) {						
						String[] disk=result.split(",");
						dtDiskUsage.setValue(0, 1, Float.parseFloat(disk[0]));
						dtDiskUsage.setValue(1, 1, Float.parseFloat(disk[1]));						
						chartDiskUsage.draw(dtDiskUsage, pieChartOptions);
					}
					
					@Override
					public void onFailure(Throwable caught) {
					}
				});
			}
		};
		timerDisk.scheduleRepeating(5000);
	}
	
	private void updateChartStats(){
		Timer timerStats=new Timer() {
			
			@Override
			public void run() {
				
			}
		};
	}
	
	private void updateJobTable(){
		
	}

	private void updateClusterTopology(){
		
	}
	
	private void initializeJobTable(){
		ArrayList<JobSummary> summaryList=new ArrayList<JobSummary>();
		JobSummary summary=new JobSummary();
		summary.jobID="201110261802_0001";
		summary.jobName="wordcount";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		
		summary=new JobSummary();
		summary.jobID="201110261802_0002";
		summary.jobName="wordcount2";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		
		summary=new JobSummary();
		summary.jobID="201110261802_0005";
		summary.jobName="wordcount5";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		
		summary=new JobSummary();
		summary.jobID="201110261802_0004";
		summary.jobName="wordcount4";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		
		summary=new JobSummary();
		summary.jobID="201110261802_0006";
		summary.jobName="wordcount6";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		
		summary=new JobSummary();
		summary.jobID="201110261802_0008";
		summary.jobName="wordcount8";
		summary.mapProgress=20.0f;
		summary.reduceProgress=0f;
		summaryList.add(summary);		
		cellTable.setRowData(summaryList);
		cellTable.redraw();
		
		
	}
	
	ArrayList<Rack> racks;
	private Label lblMbMb;
	
	private void loadTopology(){
		DashboardInitializerServiceAsync async=GWT.create(DashboardInitializerService.class);
		async.getTopology(new AsyncCallback<ArrayList<Rack>>() {
			
			@Override
			public void onSuccess(ArrayList<Rack> result) {
				racks=result;
				displayTopology();
			}
			
			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
	private void displayTopology(){
		for(Rack rack:racks){
			RackView rackview=new RackView(rack);
			horizontalPanel.add(rackview);
		}
		
	}
}
